<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <h:form id="userForm" enctype="multipart/form-data">
                <br/>
                <h2 class="title">Pesquisando Bairro</h2>
                <p:growl id="messages" showDetail="true" autoUpdate="true"  /> 
                <br/>
                <p:panel id="fatorPanel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix">
                    <h4 class="title">Dados Gerais</h4>
                    <p:outputLabel value="Cidade: " styleClass="grid_3"/>
                    <p:autoComplete styleClass="grid_16"  dropdown="true" converter="cidadeconverter"   
                                    var="cityValue" itemLabel="#{cityValue.nome.toString().concat(' - ')}#{cityValue.estado.sgl}" 
                                    itemValue="#{cityValue}" value="#{managerPesquisarBairro.cidade}"
                                    scrollHeight="200" forceSelection="true"
                                    completeMethod="#{managerPesquisarBairro.autocompleteCity}" />

                    <div class="clear"/>
                    <p:outputLabel value="Bairro:" styleClass="grid_3" />
                    <p:inputText  styleClass="grid_15"
                                  value="#{managerPesquisarBairro.bairro.nome}" />
                    <div class="clear"/>

                    <div class="buttonAction">
                        <p:commandButton id="pesquisarCommandButton" value="Pesquisar" icon="ui-icon-search"
                                         update="bairroTable"
                                         actionListener="#{managerPesquisarBairro.pesquisar()}"
                                         styleClass="ui-priority-primary" />
                        <p:commandButton id="bt_clear" value="Limpar" icon="ui-icon-clean"
                                         actionListener="#{managerPesquisarBairro.limpar()}"
                                         update="@form" />
                    </div >

                    <p:blockUI id="BLOCK" block="resultPanel" trigger="pesquisarCommandButton, bairroTable" > 
                        <p:graphicImage value="media/images/ajax-loader.gif"/>
                    </p:blockUI> 

                    <h4 class="title">Resultado</h4>
                    <p:panel id="resultPanel" style="background: none; border: none;" 
                             styleClass="container_24 clearfix ">

                        <p:dataTable id="bairroTable" var="item" value="#{managerPesquisarBairro.dataModel}" 
                                     styleClass="grid_24" rowIndexVar="rowid"
                                     binding="#{managerPesquisarBairro.searchResults}"
                                     rows="5" paginator="true" lazy="true"   
                                     paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                                     currentPageReportTemplate="{currentPage} de {totalPages}"
                                     paginatorPosition="bottom" emptyMessage="Nenhum registro encontrado"
                                     style="white-space: pre-wrap;">

                            <f:facet name="header">
                                <p:outputLabel value="Bairro" />
                            </f:facet> 
                            <p:column headerText="Ação" width="120">
                                <p:button title="Editar"
                                          href="editarbairro.xhtml?editBairro=#{item.id}"
                                          icon="ui-icon-pencil"/>
                                <p:button title="Visualizar"
                                          href="visualizarbairro.xhtml?visBairro=#{item.id}"
                                          icon="ui-icon-zoomin"/>
                                <p:commandButton update="@form" title="Excluir"
                                                 oncomplete="dlg.show()" style="margin-left: -4px"
                                                 icon="ui-icon-trash">
                                    <!--<f:setPropertyActionListener target="{managerImovel.imovelDelete}" value="{item}" />-->
                                </p:commandButton>


                            </p:column>

                            <p:column headerText="Cod Bairro" width="250">  
                                <h:outputText value="#{item.codBairro}" />
                                <br/>
                            </p:column>
                            <p:column headerText="Bairro">  
                                <h:outputText value="#{item.nome}"/>
                            </p:column> 

                        </p:dataTable> 

                    </p:panel>

                    <p:dialog id="modalDialog" header="Confirmação de remoção" widgetVar="dlg" modal="true" 
                              height="80" closable="true" resizable="false" >
                        <!--<h:outputText value="Tem certeza que deseja remover este imóvel ?" />-->
                        <!--                    <h:outputText value="Permissão só ao administrador" />-->
                        <div class="buttonAction">
                            <!--                        <p:commandButton value="Sim"
                                                                     actionListener="{managerImovel.delete()}"
                                                                     update="@form"
                                                                     icon="ui-icon-check"/>
                                                    <p:commandButton value="Não" icon="ui-icon-close"
                                                                     oncomplete="dlg.hide()" />-->

                            <h:outputText value="Exclusão só com autorização superior" />
                        </div>
                    </p:dialog>
                </p:panel>
            </h:form>
        </ui:define>
    </ui:composition>
</html>
